﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using CE.Provider;
using CE.Global;
using CE.TravelInsurance;

public partial class Provider_TravelInsurance_ViewProviderTIAge : System.Web.UI.Page
{
    string PageName = "CXTI";
    string SubPageName = "CXTIAGELG";
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session[CE.Global.General.UserId] == null || Session[CE.Global.General.ProviderCompanyId] == null)
        {
            Response.Redirect("~/Provider/ProviderSecureLogin.aspx");
        }
        CheckMainPageAccess();
        CheckSubPageAccess();

        if (!IsPostBack)
        {
            txtProviderComId.Text = Session[CE.Global.General.ProviderCompanyId].ToString();            
        }
    }

    protected void ibtBack_Click(object sender, ImageClickEventArgs e)
    {
        Response.Redirect("~/Provider/TravelInsurance/TravelInsuranceHome.aspx");
    }

    //protected void grvTI_RowDataBound(Object src, GridViewRowEventArgs e)
    //{
    //    if (e.Row.RowType == DataControlRowType.DataRow)
    //    {
    //        if (e.Row.Cells[2].Text == "STD")
    //            e.Row.Cells[2].Text = "Standard Cover";
    //        else if (e.Row.Cells[2].Text == "MED")
    //            e.Row.Cells[2].Text = "Medium Cover";
    //        else
    //            e.Row.Cells[2].Text = "High Cover";

    //    }
    //}
    
    public static string GetPlanName(object oProvId, object oPlan, object oCoverage)
    {
        string plan = "";

        TAQuoteResult _ta = new TAQuoteResult();
        TAQuoteResultDB _tadb = new TAQuoteResultDB();

        _ta = _tadb.GetTASelectSingleItemSelected(Convert.ToInt64(oProvId), oPlan.ToString(), oCoverage.ToString());

        if (_ta != null)
        {
            plan = _ta.PlanName;
        }

        return plan;

    }

    private void CheckMainPageAccess()
    {
        Int64 PageAccess = General.GetProviderMainPageAccess(Convert.ToInt64(Session[General.ProviderCompanyId].ToString()),
                                                        Convert.ToInt64(Session[General.UserId].ToString()), PageName);
        if (PageAccess == 0)
        {
            //Response.Redirect("~/Provider/UserMessage.aspx?errorcode=2000");
            Response.Redirect("~/Provider/UserMessage.aspx?mt=UM&ec=2000");
        }
    }

    private void CheckSubPageAccess()
    {
        Int64 PageAccess = General.GetProviderSubPageAccess(Convert.ToInt64(Session[General.ProviderCompanyId].ToString()),
                                                        Convert.ToInt64(Session[General.UserId].ToString()), SubPageName);
        if (PageAccess == 0)
        {
            //Response.Redirect("~/Provider/UserMessage.aspx?errorcode=2000");
            Response.Redirect("~/Provider/UserMessage.aspx?mt=UM&ec=2000");
        }
        //else if (PageAccess == 100)
        //{
        //    .Visible = false;
        //}
    }

}
